import { defineStore } from "pinia"
import Map from 'ol/Map'
import OverLay from 'ol/Overlay'

export const defaultMapStore = defineStore('defaultMapStore', () => {
  let defaultMap: Map | null = null, defaultAnchor: OverLay | null = null,
    historyActive: boolean | null = null, toggleCenter: number[] | null = null
  function setMap(map: Map) {
    defaultMap = map
  }
  function getMap() {
    return defaultMap
  }
  function setAnchor(anchor: OverLay) {
    defaultAnchor = anchor
  }
  function getAnchor() {
    return defaultAnchor
  }
  function setActive(active: boolean) {
    historyActive = active
  }
  function getActive() {
    return historyActive
  }
  function setToggleCenter(center: number[]) {
    toggleCenter = center
  }
  function getToggleCenter() {
    return toggleCenter
  }
  return {
    defaultMap, setMap, getMap,
    defaultAnchor, setAnchor, getAnchor,
    historyActive, setActive, getActive,
    toggleCenter, setToggleCenter, getToggleCenter
  }
})